package api

import (
	"github.com/gin-gonic/gin"
	"monitoring-api/service"
)

func UserRegister(c *gin.Context) {
	var service service.UserRegisterService
	if err := c.ShouldBind(&service); err == nil {
		res := service.Register()
		c.JSON(200, res)
	} else {
		c.JSON(500, gin.H{
			"message": err.Error(),
		})
	}
}

func UserLogin(c *gin.Context) {
	var service service.UserLoginService
	if err := c.ShouldBind(&service); err == nil {
		res := service.Login(c)
		c.JSON(200, res)
	} else {
		c.JSON(500, gin.H{
			"code": 404,
			"msg":  err.Error(),
		})
	}
}

func UserInfo(c *gin.Context) {
	var service service.UserInfoService
	res := service.Info(c)
	c.JSON(200, res)
}
